Skip to content

chore(vetkeys): split basic_bls_signing into self-contained motoko + rust examples#1444

Open
marc0olo wants to merge 8 commits into
masterfrom
chore/split-vetkeys-basic-bls-signing
Open

chore(vetkeys): split basic_bls_signing into self-contained motoko + rust examples#1444
marc0olo wants to merge 8 commits into
masterfrom
chore/split-vetkeys-basic-bls-signing

Conversation

@marc0olo

Copy link
Copy Markdown
Member

Summary

Splits the vetkeys basic_bls_signing example into two self-contained examples (one per language) — the same restructure as #1443 (basic_ibe). Previously it lived only under rust/vetkeys/basic_bls_signing/ with a shared frontend/ symlinked into motoko/ and rust/ subdirs.

motoko/vetkeys/basic_bls_signing/   backend/app.mo + own frontend/ + icp.yaml + mops.toml
rust/vetkeys/basic_bls_signing/     backend/ (flattened) + own frontend/ + icp.yaml + Cargo.toml

Frontend

  • Duplicated per language; bindings generated by the @icp-sdk/bindgen Vite plugin from the committed backend/backend.did (replaces the shared scripts/gen_bindings.sh).
  • Slimmed (dropped eslint/gen_bindings.sh and the BACKEND-env dev logic); added a root workspace package.json so npm run dev / npm run build run from the example root.

Backend

  • Motoko: idiomatic camelCase interface (signMessage, getMySignatures, getMyVerificationKey). moc 1.11.0 + --default-persistent-actors (dropped the redundant persistent keyword); dropped unused sha2. Committed backend/backend.did.
  • Rust: unchanged (snake_case), relocated to the flattened layout.

Each frontend matches its own backend (Motoko camelCase / Rust snake_case).

Docs & CI

  • README split per language (cross-linked); prerequisites link each tool with its command inline.
  • vetkeys-basic-bls-signing.yml: motoko + rust jobs on the new paths, watching both, running test.sh.
  • Baked in the two Copilot fixes from chore(vetkeys): split basic_ibe into self-contained motoko + rust examples #1443: the main.ts "Canister ID not set" error names backend, and test.sh calls the query method with --query.

CODEOWNERS

Unchanged — /motoko/vetkeys/ and /rust/vetkeys/ both map to @dfinity/core-protocol.

Verification (local)

  • Motoko: frontend build + tsc --noEmit clean, icp deploy, test.sh PASS, and a signed message survives an upgrade.
  • Rust: cargo/wasm build + icp deploy, test.sh PASS.
  • Both frontends build and serve.

Part of the vetkeys split series (after #1443). Remaining: encrypted_notes_app_vetkd, password_manager, password_manager_with_metadata.

🤖 Generated with Claude Code

…rust examples

Same split as basic_ibe (#1443): move the Motoko variant to
motoko/vetkeys/basic_bls_signing and flatten the Rust variant to
rust/vetkeys/basic_bls_signing, each self-contained with its own frontend
copy (previously a shared frontend symlinked into motoko/ and rust/ subdirs).

- Frontend: per-language copy; bindings via the @icp-sdk/bindgen Vite plugin
  from the committed backend/backend.did (replaces scripts/gen_bindings.sh);
  dropped eslint; root workspace package.json so `npm run dev` runs from the
  example root.
- Motoko: idiomatic camelCase interface (signMessage, getMySignatures,
  getMyVerificationKey); moc 1.11.0 + --default-persistent-actors (dropped
  `persistent`); dropped unused sha2 dep; committed backend/backend.did.
- Rust: unchanged (snake_case), relocated to the flattened layout.
- READMEs split per language (linked prerequisites); test.sh added (query
  method called with --query); CI split into motoko + rust jobs on the new
  paths. Baked in the two Copilot fixes from #1443 (error message names
  `backend`; --query for the query method).

CODEOWNERS unchanged: /motoko/vetkeys/ and /rust/vetkeys/ both map to
@dfinity/core-protocol.

Verified: Motoko deploy + test.sh + signature survives an upgrade; Rust
cargo build + deploy + test.sh; both frontends build/typecheck/serve.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…p Makefile

- Bump the Rust recipe to @dfinity/rust@v3.3.0 and rename the Cargo package to
  `backend`, so the recipe no longer needs a custom `package:` in its
  configuration (matches daily_planner and the other migrated rust examples).
- Drop backend/Makefile; advertise candid regeneration directly in the README
  via `icp build backend && candid-extractor … > backend/backend.did`
  (the Makefile's `rm -rf .icp` clean target was also wrong — only .icp/cache
  should ever be wiped, and that isn't advertised elsewhere anyway).

Verified: rust deploy + test.sh pass; `icp build backend` produces backend.wasm.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures the vetkeys/basic_bls_signing example into two fully self-contained examples (Motoko + Rust), each with its own frontend, backend config, and build/test entrypoints—mirroring the earlier basic_ibe split and removing the prior shared-frontend/symlink workflow.

Changes:

  • Split the example into motoko/vetkeys/basic_bls_signing and rust/vetkeys/basic_bls_signing, each with independent frontend + project root workspace package.json.
  • Replaced the legacy bindings generation script with @icp-sdk/bindgen via the Vite plugin, generating bindings from committed backend/backend.did.
  • Updated CI workflow to run deploy + test.sh for both language variants on the new paths.

Reviewed changes

Copilot reviewed 31 out of 38 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
rust/vetkeys/basic_bls_signing/test.sh Adds a basic CLI test script for the Rust variant.
rust/vetkeys/basic_bls_signing/rust/backend/Makefile Removes legacy wasm build / candid extraction Make targets.
rust/vetkeys/basic_bls_signing/rust-toolchain.toml Adds wasm32 target configuration for the Rust toolchain.
rust/vetkeys/basic_bls_signing/README.md Updates Rust README for the new self-contained layout, workflow, and bindgen approach.
rust/vetkeys/basic_bls_signing/package.json Adds a root workspace package.json to run frontend scripts from the example root.
rust/vetkeys/basic_bls_signing/motoko/mops.toml Removes the old Motoko config from the former shared Rust directory layout.
rust/vetkeys/basic_bls_signing/icp.yaml Renames canisters to backend/frontend, updates rust recipe version, and updates frontend build dir/commands.
rust/vetkeys/basic_bls_signing/frontend/vite.config.ts Switches dev/build flow to @icp-sdk/bindgen and simplifies dev-server wiring for local deploys.
rust/vetkeys/basic_bls_signing/frontend/src/main.ts Updates frontend bindings import path and canister env key from basic_bls_signing to backend.
rust/vetkeys/basic_bls_signing/frontend/scripts/gen_bindings.sh Removes legacy binding generation script.
rust/vetkeys/basic_bls_signing/frontend/package.json Simplifies frontend package scripts/deps and adds @icp-sdk/bindgen.
rust/vetkeys/basic_bls_signing/frontend/eslint.config.mjs Removes ESLint config as part of frontend slimming.
rust/vetkeys/basic_bls_signing/frontend/.gitignore Adds ignores for node_modules, dist, and generated bindings.
rust/vetkeys/basic_bls_signing/Cargo.toml Adds a workspace root and release profile settings for the Rust example.
rust/vetkeys/basic_bls_signing/backend/src/types.rs Adds backend type definitions and stable-structure serialization for signatures.
rust/vetkeys/basic_bls_signing/backend/src/lib.rs Adds the Rust canister implementation in the flattened backend/ layout.
rust/vetkeys/basic_bls_signing/backend/Cargo.toml Renames the crate to backend for the new layout.
rust/vetkeys/basic_bls_signing/backend/backend.did Adds committed Candid interface for the Rust backend.
motoko/vetkeys/basic_bls_signing/test.sh Adds a basic CLI test script for the Motoko variant.
motoko/vetkeys/basic_bls_signing/README.md Adds Motoko README aligned with the new self-contained structure and tooling.
motoko/vetkeys/basic_bls_signing/package.json Adds a root workspace package.json to run frontend scripts from the example root.
motoko/vetkeys/basic_bls_signing/mops.toml Adds Motoko toolchain/deps and candid configuration for the Motoko variant.
motoko/vetkeys/basic_bls_signing/icp.yaml Adds Motoko icp.yaml with backend/frontend canisters and asset build steps.
motoko/vetkeys/basic_bls_signing/frontend/vite.config.ts Adds Vite config with bindgen plugin and local-dev cookie/proxy wiring.
motoko/vetkeys/basic_bls_signing/frontend/tsconfig.json Adds TypeScript configuration for the Motoko frontend.
motoko/vetkeys/basic_bls_signing/frontend/src/vite-end.d.ts Adds Vite client type reference.
motoko/vetkeys/basic_bls_signing/frontend/src/style.css Adds frontend styling.
motoko/vetkeys/basic_bls_signing/frontend/src/main.ts Adds the Motoko frontend app using generated bindings and II auth client wiring.
motoko/vetkeys/basic_bls_signing/frontend/public/.ic-assets.json5 Adds hardened asset canister security policy headers.
motoko/vetkeys/basic_bls_signing/frontend/package.json Adds Motoko frontend package scripts/deps and bindgen devDependency.
motoko/vetkeys/basic_bls_signing/frontend/index.html Adds Vite entry HTML.
motoko/vetkeys/basic_bls_signing/frontend/.gitignore Adds ignores for node_modules, dist, and generated bindings.
motoko/vetkeys/basic_bls_signing/backend/backend.did Adds committed Candid interface for the Motoko backend (camelCase API).
motoko/vetkeys/basic_bls_signing/backend/app.mo Adds Motoko canister implementation with camelCase API surface.
.github/workflows/vetkeys-basic-bls-signing.yml Updates CI to run separate Motoko + Rust jobs on the new paths, including test.sh.
Comments suppressed due to low confidence (1)

motoko/vetkeys/basic_bls_signing/backend/app.mo:13

  • shared actor class relies on --default-persistent-actors, but per AGENTS.md:226 that flag does not make actor class persistent. Since this actor class stores mutable state in signatures, upgrades may lose user signatures unless the class is explicitly persistent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust/vetkeys/basic_bls_signing/test.sh Outdated
Comment thread motoko/vetkeys/basic_bls_signing/test.sh Outdated
Comment thread rust/vetkeys/basic_bls_signing/test.sh Outdated
Comment thread rust/vetkeys/basic_bls_signing/test.sh Outdated
Comment thread motoko/vetkeys/basic_bls_signing/test.sh Outdated
Comment thread motoko/vetkeys/basic_bls_signing/test.sh Outdated
marc0olo and others added 2 commits July 17, 2026 10:42
… test.sh

Address Copilot review:
- Use `persistent actor class` explicitly (drop the redundant class-level
  `shared` and the `--default-persistent-actors` mops arg). Empirically the
  flag DID persist this main-canister actor class across upgrades — AGENTS.md's
  caveat is about actor classes spawned as sub-WASMs, not a main canister that
  is an actor class for its init arg — but explicit `persistent` is unambiguous
  and matches AGENTS.md's literal guidance. Verified: state survives an upgrade.
- Drop test.sh (motoko + rust) and run deploy-only CI. The example never had a
  test.sh on master; the deploy itself verifies build + install.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…edundant `shared`

Revert the explicit `persistent` detour: keep `--default-persistent-actors`
(no `persistent` keyword) — the flag is required today (moc 1.11.0 errors M0219
otherwise) and is the forward-compatible choice, and it provably persists this
main-canister actor class across upgrades. Keep the actor class as a plain
`actor class` (the previous class-level `shared` was unnecessary — the `shared`
that matters is on the `public shared ({ caller })` methods).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@marc0olo

Copy link
Copy Markdown
Member Author

Addressed the Copilot review:

  • test.sh comments — resolved by removing test.sh from this example. It had none on master (only the basic_vetkd template ships one), so CI is now deploy-only, matching the original workflow. The deploy verifies build + install for both backends and the frontend.

  • Persistence (suppressed comment) — verified empirically that the --default-persistent-actors flag does persist this main-canister actor class: signed a message, ran icp deploy again (an upgrade, not reinstall), and the signature survived. AGENTS.md:226 refers to actor classes spawned as sub-WASMs (child canisters, e.g. canister_factory), not a main canister that is an actor class only to take its keyName init arg. Dropping the flag isn't an option either — without it and without persistent, moc 1.11.0 hard-errors M0219 (vars implicitly transient). Kept the flag (no persistent keyword) as the forward-compatible choice, and dropped the redundant class-level shared (shared actor classactor class; only the method-level public shared ({ caller }) is needed).

@marc0olo
marc0olo marked this pull request as ready for review July 17, 2026 08:58
@marc0olo
marc0olo requested review from a team as code owners July 17, 2026 08:58
marc0olo and others added 4 commits July 17, 2026 12:05
"ask the canister (IC smart contract) to produce" -> "ask the canister to produce".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace "dapp" with "app" in READMEs and code comments and normalize the
security best-practices link to
https://docs.internetcomputer.org/guides/security/overview/. The functional
vetKD domain-separator string ("basic_bls_signing_dapp") is left unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ology

The `signatures` field is retained across upgrades because it is not declared
`transient` — there is no `stable` keyword in use. Update the comment to
describe this accurately.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…"dapp"

Change the vetKD domain-separator string from "basic_bls_signing_dapp" to
"basic_bls_signing_app" in both backends (Rust array length 22 -> 21). These are
fresh examples with no previously derived keys to stay compatible with, so the
change is safe. Both backends compile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 36 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

motoko/vetkeys/basic_bls_signing/backend/app.mo:13

  • The canister is defined as a non-persistent actor class, but later comments (and the example’s intended behavior) assume signatures survives upgrades. With --default-persistent-actors, the top-level actor is made persistent by default, but actor class declarations still need to be explicitly persistent to retain state across upgrades.
    rust/vetkeys/basic_bls_signing/icp.yaml:6
  • The Rust canister recipe’s configuration block is missing package: backend. Most Rust examples in this repo specify the Cargo package explicitly; without it the build can fail or select the wrong crate when using a workspace layout.

Comment thread .github/workflows/vetkeys-basic-bls-signing.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants